package com.codeduck.guava.basic;

import com.google.common.base.Throwables;

import java.io.IOException;
import java.sql.SQLException;

/**
 * Throwables: Guava's Throwables utility can frequently simplify dealing with exceptions.
 * - 参考：https://github.com/google/guava/wiki/ThrowablesExplained
 *
 * @author: <a href="mailto:codeduck@163.com">Codeduck</a>
 * @createDate: 2022-05-19
 */
public class Demo05 {
    public static void main(String[] args)  {
//        try {
//            someMethodThatCouldThrowAnything();
//        } catch (IKnowWhatToDoWithThisException e) {
//            handle(e);
//        } catch (Throwable t) {
//            Throwables.throwIfInstanceOf(t, IOException.class);  // 当且仅当它是 IOException 的实例时，按原样传播可抛出的内容。
//            Throwables.throwIfInstanceOf(t, SQLException.class);
//            Throwables.throwIfUnchecked(t);
//            throw new RuntimeException(t);
//        }
    }
}
